# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=sslyze
pkgver=6.1.0
_pyver=3.13
pkgrel=2
groups=('blackarch' 'blackarch-crypto' 'blackarch-scanner')
pkgdesc='Python tool for analyzing the configuration of SSL servers and for identifying misconfigurations.'
arch=('x86_64' 'aarch64')
url='https://github.com/nabla-c0d3/sslyze'
license=('GPL2')
depends=('python' 'python-tls-parser' 'python-cryptography' 'python-nassl'
         'python-typing_extensions' 'python-pydantic' 'python-pyopenssl')
makedepends=('python-build' 'python-pip')
source=("https://github.com/nabla-c0d3/$pkgname/archive/$pkgver.zip")
sha512sums=('f19c144d83d1b5bb452a75e6b49838868d4d2b6b239cd9e43e9cc22831abce179de2609815ce4f51dbdbd92bc09a5d8b816718a5c93b4a85baec55214cf743fe')

build() {
  cd "$pkgname-$pkgver"

  python -m build --wheel --outdir="$startdir/dist"
}

prepare() {
  cd "$pkgname-$pkgver"

  sed -i 's|pydantic>=1.7,<1.10|pydantic|g' setup.py
}

package() {
  cd "$pkgname-$pkgver"

  pip install \
    --verbose \
    --disable-pip-version-check \
    --no-warn-script-location \
    --ignore-installed \
    --no-compile \
    --no-deps \
    --root="$pkgdir" \
    --prefix=/usr \
    --no-index \
    --find-links="file://$startdir/dist" \
    "$pkgname"

  install -Dm 644 LICENSE.txt "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  rm -rf "$pkgdir/usr/lib/python$_pyver/site-packages/tests"

  sed -i "s/sslyze==$pkgver/sslyze/" "$pkgdir/usr/bin/$pkgname"
}

